package cb

import (
	"net/http"
  "fmt"
	"github.com/labstack/echo"
  ewa "gitlab.supor.com/jinquan/ewa"
)

var RedisConnArgs_ = ewa.RedisConnArgs {
  Qname: "example3",
  Network: "tcp",
  Address: "10.0.1.7:6379",
  Password: "1231@supor",
}


/* Restrict Route POST, 
   需要cookies, 
   需要token验证  */
func Cb_api0(c echo.Context) error {
  //fmt.Printf("Path: %s\n", c.Path())	//such like as '/test.html'
  utype, uri := ewa.HttpReqPathSuffix(c.Path())

  if utype == ewa.URITYPE_RES {

  }else if utype == ewa.URITYPE_API {
      // redis lpush
      r:=ewa.CreateRedisConn(RedisConnArgs_)

      ewa.RedisQlPush(r, "Q0", ewa.PostFormParamsJson(c))
      ewa.RemoveRedisConn(r)

      reply:=fmt.Sprintf("%s redis lpush: OK", uri)
      return c.String(http.StatusOK, reply)
  }
  return nil
}
